package designPattern.factory;

/**
 * Author: hu
 * Date: 2022/6/10 15:13
 */
public class T {

    public static A getA(String str){
        switch(str){
            case  "B": return new B();
            case  "C": return new C();
        }
        return null;
    }

    public static void main(String[] args) {
        A a = T.getA("B");
        a.name();
        A a1 = T.getA("C");
        a1.name();
    }
}
 interface A {
    void name();
}
class  B implements A{
    @Override
    public void name() {
        System.out.println("this is B");
    }
}

class  C implements A{

    @Override
    public void name() {
        System.out.println("this is C");
    }
}
